﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Waker.Entitys
{
    /// <summary>
    /// 泛型类
    /// </summary>
    /// <typeparam name="T"></typeparam> 
    public class En_Result<T>
    {

        public string Message { get; set; }


        public bool IsSuccess { get; set; }


        public T ResultData { get; set; }
        /// <summary>
        /// 成功消息
        /// </summary>
        /// <returns></returns>
        public static En_Result<T> CreateSuccessResult()
        {
            return new En_Result<T>() { IsSuccess = true };
        }

        /// <summary>
        /// 成功消息
        /// </summary>
        /// <returns></returns>
        public static En_Result<T> CreateSuccessResult(T data)
        {
            return new En_Result<T>() { IsSuccess = true, ResultData = data };
        }
        /// <summary>
        /// 失败消息
        /// </summary>
        /// <param name="failMsg"></param>
        /// <returns></returns>
        public static En_Result<T> CreateFailedResult(string failMsg)
        {
            return new En_Result<T> { IsSuccess = false, Message = failMsg };
        }

        /// <summary>
        /// 失败消息
        /// </summary>
        /// <param name="failMsg"></param>
        /// <returns></returns>
        public static En_Result<T> CreateFailedResult(T data)
        {
            return new En_Result<T> { IsSuccess = false, ResultData = data };
        }

        /// <summary>
        /// 失败消息
        /// </summary>
        /// <param name="failMsg"></param>
        /// <returns></returns>
        public static En_Result<T> CreateFailedResult()
        {
            return new En_Result<T> { IsSuccess = false };
        }
    }

    /// <summary>
    /// 非泛型
    /// </summary> 
    public class En_Result
    {

        public string Message { get; set; }


        public bool IsSuccess { get; set; }


        //public object ResultData { get; set; }
        /// <summary>
        /// 成功消息
        /// </summary>
        /// <returns></returns>
        public static En_Result CreateSuccessResult()
        {
            return new En_Result() { IsSuccess = true };
        }

        /// <summary>
        /// 成功消息
        /// </summary>
        /// <returns></returns>
        //public static En_Result CreateSuccessResult(object data)
        //{
        //    return new En_Result() { IsSuccess = true, ResultData = data };
        //}
        /// <summary>
        /// 失败消息
        /// </summary>
        /// <param name="failMsg"></param>
        /// <returns></returns>
        public static En_Result CreateFailedResult(string failMsg)
        {
            return new En_Result { IsSuccess = false, Message = failMsg };
        }
    }
}
